package com.jblog.controller.front.action.blog;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jblog.controller.front.action.BaseAct;
import com.jblog.core.model.blog.Post;

@Controller
@RequestMapping("/post")
public class PostAct extends BaseAct {
        
    @RequestMapping(method = RequestMethod.GET)
    public String index(HttpServletRequest request, ModelMap model) {
        return "forward:/";
    }
    
    @RequestMapping(value = "/{alias}", method = RequestMethod.GET)
    public String alias(HttpServletRequest request, ModelMap model, @PathVariable String alias) {
        Post post = iblog.findPostByAlisa(alias);
        model.put("post", post);
        model.put("keywords", toKeywords(post));
        
        return F(request, model, "blog/post");
    }

}